package org.yi.fc.entity;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class FCategory extends Model<FCategory>{

	private static final long serialVersionUID = 3366166958697051523L;
	
	/**
	 * 子栏目
	 */
	private List<FCategory> sub;
	
	public static FCategory dao = new FCategory();
	

	public List<FCategory> getSub() {
		return sub;
	}
	public void setSub(List<FCategory> sub) {
		this.sub = sub;
	}

	/**
	 * 暂时取2级目录， 以后需要再扩展
	 * @return
	 */
	public List<FCategory> getAll() {
		List<FCategory> top = find("select * from f_category where pid is null or pid = ''");
		for(FCategory f : top) {
			f.setSub(find("select * from f_category where pid = ?", f.getBigInteger("id")));
		}
		return top;
	}
	
}
